import { GET_USER_INFO } from "../../service/wx"

export default {
  state: () => ({
    userInfo: null
  }),

  mutations: {
    setUserInfo (state, userInfo) {
      state.userInfo = userInfo
    }
  },

  actions: {
    async getUserInfo ({commit}, {code}) {
      const res = await GET_USER_INFO({code})
      console.log(res)
      if (!res.code) {
      localStorage.setItem('userInfo', JSON.stringify(res))
        commit('setUserInfo', res.data)
      }
    }
  }
}